<template>
	<view class="content">
		<!-- 顶部标题栏 -->
		<view class="header">备忘录</view>
		<!-- 搜索框 -->
		<view class="search-box">
			<image src="/static/search-icon.png" class="search-icon"></image>
			<input type="text" placeholder="搜索笔记" v-model="searchValue" />
		</view>
		<!-- 笔记列表 -->
		<view class="note-list">
			<view class="note-item" v-for="(note, index) in filteredNotes" :key="index">
				<view class="note-info">
					<text class="note-title">{{ note.title }}</text>
					<text class="note-time">{{ note.time }}</text>
				</view>
				<image src="/static/delete-icon.png" class="delete-icon" @click="deleteNote(note.id)"></image>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="bottom-btn">
			<image src="/static/note-icon.png" class="bottom-icon"></image>
			<text>笔记</text>
		</view>
		<view class="bottom-btn">
			<image src="/static/todo-icon.png" class="bottom-icon"></image>
			<text>代办</text>
		</view>
		<!-- 悬浮添加按钮 -->
		<image src="/static/add-icon.png" class="float-add-btn" @click="goToAdd"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				notes: [{

					],
					searchValue: ''
				}
			},
			computed: {
					filteredNotes() {
						if (!this.searchValue) {
							return this.notes;
						}
						return this.notes.filter(note => note.title.includes(this.searchValue));
					}
				},
				methods: {
					deleteNote(id) {
						uni.showModal({
							title: '提示',
							content: '确定要删除这条笔记吗？',
							success: (res) => {
								if (res.confirm) {
									this.notes = this.notes.filter(note => note.id !== id);
									uni.showToast({
										title: '删除成功',
										icon: 'none'
									});
								}
							}
						});
					},
					goToAdd() {
						uni.navigateTo({
							url: '../memo/add'
						});
					}
				}
		}
</script>

<style>

</style>